import * as financeService from '../../services/finance/finance';
export default {
  namespace: 'finance',
  state:{
    customerPayRecordsPage:{},
    inOutCurrentDayRecords:[],
    inOutDayRecords:[],
    serviceDayMoneys:[],
    dayMoneys:[],
    dashBoard:{},
    monthMoneys:[]
  },
  reducers: {
    updateCustomerPayRecordsPage(state, {payload}) {
      const newstate = state;
      newstate.customerPayRecordsPage = payload;
      return newstate;
    },
    updateInOutCurrentDayRecords(state, {payload}) {
      const newstate = state;
      newstate.inOutCurrentDayRecords = payload;
      return newstate;
    },
    updateInOutDayRecords(state, {payload}) {
      const newstate = state;
      newstate.inOutDayRecords = payload;
      return newstate;
    },
    updateServiceDayMoneyReport(state, {payload}) {
      const newstate = state;
      newstate.serviceDayMoneys = payload;
      return newstate;
    },
    updateDayMoneyCharts(state, {payload}) {
      const newstate = state;
      newstate.dayMoneys = payload;
      return newstate;
    },
    updateMonthMoneyCharts(state, {payload}) {
      const newstate = state;
      newstate.monthMoneys = payload;
      return newstate;
    },
    updateDashboard(state, {payload}) {
      const newstate = state;
      newstate.dashBoard = payload;
      return newstate;
    },
  },
  effects: {
    *e_getCustomerPayRecordsPage({payload}, {call, put}) {
      const {data} = yield call(financeService.getPageCustomerPayRecordPage,payload);
      yield put({type: 'updateCustomerPayRecordsPage', payload: data});
    },
    *e_getInOutCurrentDayRecords({payload}, {call, put}) {
      const {data} = yield call(financeService.getInOutCurrentDayRecord);
      yield put({type: 'updateInOutCurrentDayRecords', payload: data});
    },
    *e_getInOutDayRecords({payload}, {call, put}) {
      const {data} = yield call(financeService.getInOutDayRecord,payload);
      yield put({type: 'updateInOutDayRecords', payload: data});
    },
    *e_getServiceDayMoneyReport({payload}, {call, put}) {
      const {data} = yield call(financeService.getServiceDayMoneyReport,payload);
      yield put({type: 'updateServiceDayMoneyReport', payload: data});
    },
    *e_getDayMoneyCharts({payload}, {call, put}) {
      const {data} = yield call(financeService.getDayMoneyCharts,payload);
      yield put({type: 'updateDayMoneyCharts', payload: data});
    },
    *e_getMonthMoneyCharts({payload}, {call, put}) {
      const {data} = yield call(financeService.getMonthMoneyCharts,payload);
      yield put({type: 'updateMonthMoneyCharts', payload: data});
    },
    *e_getDashBoard({payload}, {call, put}) {
      const {data} = yield call(financeService.getDashBoard,payload);
      yield put({type: 'updateDashboard', payload: data});
    },

  },
}
